package com.mail.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mail.pojo.Mail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MailMapper extends BaseMapper<Mail> {
    @Select("select account_email from mail where id=#{id}")
    String queryAccountEmailById(@Param(("id")) long id);

    @Select("select status from mail where id=#{id}")
    String queryStatusById(@Param(("id")) long id);

    @Update("update mail set status=#{status} where id=#{id}")
    void updateStatus(@Param(("status")) String status,@Param(("id")) long id);

    @Update("update mail set regular_time=#{regularTime} where id=#{id}")
    void updateCronById(@Param("regularTime") String regularTime,@Param("id") long id);

    @Select("select * from mail where user_id=#{userId} and team_id=#{teamId} limit #{page},#{limit}")
    List<Mail> queryTimedMail(@Param("userId") long userId, @Param("teamId") long teamId, @Param("page") int page, @Param("limit")int limit);

    @Select("select count(*) from mail where user_id=#{userId} and team_id=#{teamId}")
    long queryTimedMailCount(@Param("userId") long userId, @Param("teamId") long teamId);

    @Select("select * from mail where team_id=#{teamId} limit #{page},#{limit}")
    List<Mail> queryTimedTeam(@Param("teamId") long teamId,@Param("page") int page,@Param("limit")int limit);

    @Select("select count(*) from mail where team_id=#{teamId}")
    long queryTimedTeamCount(@Param("teamId") long teamId);

    @Select("select * from mail where user_id=#{userId} and person_or_team=0 limit #{page},#{limit}")
    List<Mail> queryTimedAccountEmail(@Param("userId") long userId,@Param("page") int page, @Param("limit")int limit);

    @Select("select count(*) from mail where user_id=#{userId} and person_or_team=0")
    long queryTimedAccountEmailCount(@Param("userId") long userId);


}
